import request from '@/utils/request'

const basePath = '/jpower-system'

/**
 * @description:
 * @param {type}
 * @return {type}
 */
export function list(params = {}) {
  return request({
    url: basePath + '/core/param/list',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 通过ID获取用户详情
 * @param {type}
 * @return {type}
 */
export function info(id) {
  return request({
    url: basePath + '/core/param/queryById',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { id }
  })
}

/**
 * @description: 新增系统参数
 * @param {*} params
 * @return {*}
 */
export function add(params) {
  return request({
    url: basePath + '/core/param/add',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 删除系统参数
 * @param {*} id
 * @return {*}
 */
export function remove(id) {
  return request({
    url: basePath + '/core/param/delete',
    method: 'delete',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { id }
  })
}

/**
 * @description: 全部生效
 * @param {*}
 * @return {*}
 */
export function effectAll() {
  return request({
    url: basePath + '/core/param/effectAll',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}

/**
 * @description: 立即生效一个参数
 * @param {*} code
 * @return {*}
 */
export function takeEffect(code) {
  return request({
    url: basePath + '/core/param/takeEffect',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { code }
  })
}

/**
 * @description: 更新参数
 * @param {*} params
 * @return {*}
 */
export function update(params) {
  return request({
    url: basePath + '/core/param/update',
    method: 'put',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

